package com.gexiaobao.pigeon.ui.adapter

import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.SignGroupList
import com.gexiaobao.pigeon.databinding.ItemPassSignOrderDetailBinding
import java.lang.StringBuilder

/**
 * @Author      : hxw
 * @Date        : 2024/7/18 13:53
 * @Describe    :
 */
class AdapterPassSignOrderDetail(data: ArrayList<SignGroupList>) :
    BaseQuickAdapter<SignGroupList, DataBindBaseViewHolder>(R.layout.item_pass_sign_order_detail, data) {
    override fun convert(holder: DataBindBaseViewHolder, item: SignGroupList) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemPassSignOrderDetailBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        val sb = StringBuilder()
        if (item.signProject.isNotEmpty()) {
            item.signProject.forEach {
                sb.append(it + "\n")
            }
        }
        holder.setText(R.id.tvGroupName, sb.toString().trim())

        if (holder.layoutPosition % 2 == 0) {//偶数
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.comm_bg))
        } else {
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.white))
        }
    }
}